﻿package mortal.game.view.common.menu
{
    import Message.Public.*;
    import extend.language.*;
    import fl.data.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;
    import mortal.game.cache.packCache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.utils.*;
    import mortal.game.view.pack.social.*;
    import mortal.mvc.core.*;

    public class ItemMenuConst extends Object
    {
        public static const USE:String = Language.getString(30001);
        public static const SHOW:String = Language.getString(30002);
        public static const TO_SALE:String = Language.getString(30003);
        public static const SPLIT:String = Language.getString(30004);
        public static const FORGING:String = Language.getString(30006);
        public static const EQUIP:String = Language.getString(30007);
        public static const EQUIPFABAO:String = Language.getString(30008);
        public static const IDENTIFYFABAO:String = Language.getString(30009);
        public static const EQUIPMOUNT:String = Language.getString(30010);
        public static const GRADE:String = Language.getString(30011);
        public static const JEWELUP:String = Language.getString(30012);
        public static const BULKUSE:String = Language.getString(30036);
        public static const APPLY:String = Language.getString(20722);
        public static const EXTRACTION:String = Language.getString(20723);
        public static const Prop:DataProvider = new DataProvider([{label:ItemMenuConst.USE}, {label:ItemMenuConst.BULKUSE}, {label:ItemMenuConst.SHOW}, {label:ItemMenuConst.SPLIT}]);
        private static const Equip:DataProvider = new DataProvider([{label:ItemMenuConst.EQUIP}, {label:ItemMenuConst.SHOW}]);
        private static const Fabao:DataProvider = new DataProvider([{label:ItemMenuConst.SHOW}, {label:ItemMenuConst.TO_SALE}]);
        private static const Task:DataProvider = new DataProvider([]);
        public static const DrugBag:DataProvider = new DataProvider([{label:ItemMenuConst.USE}]);
        public static const GuildWareHouseItem:DataProvider = new DataProvider([{label:ItemMenuConst.APPLY}, {label:ItemMenuConst.EXTRACTION}]);

        public function ItemMenuConst()
        {
            return;
        }// end function

        public static function getOpEnabled(param1:String, param2:ItemData) : Boolean
        {
            if (!param2)
            {
                return false;
            }
            switch(param1)
            {
                case ItemMenuConst.USE:
                {
                    return true;
                }
                case ItemMenuConst.SHOW:
                {
                    return true;
                }
                case ItemMenuConst.TO_SALE:
                {
                    return !ItemsUtil.isBind(param2);
                }
                case ItemMenuConst.SPLIT:
                {
                    return param2.serverData.itemAmount > 1;
                }
                case ItemMenuConst.EQUIP:
                {
                    return true;
                }
                case ItemMenuConst.EQUIPMOUNT:
                {
                    return true;
                }
                case ItemMenuConst.GRADE:
                {
                    return true;
                }
                case ItemMenuConst.JEWELUP:
                {
                    return true;
                }
                case ItemMenuConst.BULKUSE:
                {
                    return ItemsUtil.isCanBulkUse(param2);
                }
                case ItemMenuConst.APPLY:
                {
                    return !GuildConst.hasPermissions(GuildConst.ManagerWareHouse);
                }
                case ItemMenuConst.EXTRACTION:
                {
                    return GuildConst.hasPermissions(GuildConst.ManagerWareHouse);
                }
                default:
                {
                    return true;
                    break;
                }
            }
        }// end function

        public static function getDataProvider(param1:ItemData) : DataProvider
        {
            var _loc_2:* = param1.itemInfo.group;
            var _loc_3:* = param1.itemInfo.category;
            if (_loc_2 == EGroup._EGroupProp && (_loc_3 == EProp._EPropProp || _loc_3 == EProp._EPropDrug))
            {
                return ItemMenuConst.Prop;
            }
            if (_loc_2 == EGroup._EGroupStuff)
            {
                return ItemMenuConst.Prop;
            }
            if (_loc_2 == EGroup._EGroupProp && (_loc_3 == EProp._EPropEquip || _loc_3 == EProp._EPropMountEquip || _loc_3 == EProp._EPropSpriteEquip || _loc_3 == EProp._EPropGodHeadEquip || _loc_3 == EProp._EPropPet2Equip))
            {
                return ItemMenuConst.Equip;
            }
            if (_loc_2 == EGroup._EGroupProp && (_loc_3 == EProp._EPropEquip || _loc_3 == EProp._EPropMountEquip || _loc_3 == EProp._EPropFashionClothesEquip || _loc_3 == EProp._EPropFashionWingEquip || _loc_3 == EProp._EPropFashionWeaponEquip || _loc_3 == EProp._EPropFashionFightSoulEquip || _loc_3 == EProp._EPropFashionFightMethodEquip || _loc_3 == EProp._EPropFashionDragonSoulEquip || _loc_3 == EProp._EPropFashionHolyBookEquip || _loc_3 == EProp._EPropFashionWarShieldEquip || _loc_3 == EProp._EPropFashionMonsterSoulEquip))
            {
                return ItemMenuConst.Equip;
            }
            return ItemMenuConst.Prop;
        }// end function

        public static function getEnabeldAttri(param1:DataProvider, param2:ItemData) : DataProvider
        {
            var _loc_5:Object = null;
            var _loc_6:Boolean = false;
            var _loc_7:Object = null;
            var _loc_3:* = new DataProvider();
            var _loc_4:int = 0;
            while (_loc_4 < param1.length)
            {
                
                _loc_5 = param1.getItemAt(_loc_4);
                _loc_6 = getOpEnabled(_loc_5["label"], param2);
                if (_loc_6)
                {
                    _loc_7 = {label:_loc_5["label"], enabled:_loc_6};
                    _loc_3.addItem(_loc_7);
                }
                _loc_4++;
            }
            return _loc_3;
        }// end function

        public static function opearte(param1:String, param2:ItemData) : void
        {
            var _loc_3:Object = null;
            var _loc_4:Object = null;
            var _loc_5:WizardPackCache = null;
            var _loc_6:Object = null;
            switch(param1)
            {
                case ItemMenuConst.USE:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.BackPack_Use, param2));
                    break;
                }
                case ItemMenuConst.SHOW:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ChatShowItem, param2));
                    break;
                }
                case ItemMenuConst.SPLIT:
                {
                    ItemFeatureTips.splitTip(param2);
                    break;
                }
                case ItemMenuConst.EQUIP:
                {
                    if (ItemsUtil.isPrescriOutTime(param2))
                    {
                        return MsgManager.showRollTipsMsg(Language.getString(20724), MsgRollTipsType.msgRollTips3);
                    }
                    if (ItemsUtil.isEquip(param2))
                    {
                        if (!ItemsUtil.isFitCarrer(param2))
                        {
                            MsgManager.showRollTipsMsg(Language.getString(30054));
                        }
                        else if (!ItemsUtil.isEnoughLevel(param2))
                        {
                            MsgManager.showRollTipsMsg(Language.getStringByParam(20725, param2.itemInfo.level), MsgRollTipsType.msgRollTips3);
                        }
                        else if (ItemsUtil.isBind(param2))
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.BackPack_Equip, param2));
                        }
                        else
                        {
                            ItemFeatureTips.equipItem(param2);
                        }
                    }
                    else if (ItemsUtil.isHalidomEquip(param2))
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.BackPack_HalidomEquip, param2));
                    }
                    else if (ItemsUtil.isMountEquip(param2))
                    {
                        _loc_3 = new Object();
                        _loc_3.putonitemData = param2;
                        _loc_3.getoffItemData = Cache.instance.pack.mountPackCache.getEquipByType(param2.itemInfo.type);
                        if (ItemsUtil.isBind(param2))
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.MountEquip, _loc_3));
                        }
                        else
                        {
                            ItemFeatureTips.mountEquipItem(_loc_3);
                        }
                    }
                    else if (ItemsUtil.isPetEquip(param2))
                    {
                        _loc_4 = new Object();
                        _loc_4.putonitemData = param2;
                        _loc_4.getoffItemData = Cache.instance.pack.petBag.getEquipByType(param2.itemInfo.type);
                        if (ItemsUtil.isBind(param2))
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.PetEquip, _loc_4));
                        }
                        else
                        {
                            ItemFeatureTips.petEquipItem(_loc_4);
                        }
                    }
                    else if (ItemsUtil.isWizardEquip(param2))
                    {
                        _loc_5 = Cache.instance.pack.getWizardPackCacheByCode(param2.itemInfo.effectEx as int);
                        if (_loc_5)
                        {
                            _loc_6 = new Object();
                            _loc_6.putonitemData = param2;
                            _loc_6.getoffItemData = _loc_5.getEquipByType(param2.itemInfo.type);
                            _loc_6.code = param2.itemInfo.effectEx;
                            if (ItemsUtil.isBind(param2))
                            {
                                Dispatcher.dispatchEvent(new DataEvent(EventName.WizardEquip, _loc_6));
                            }
                            else
                            {
                                ItemFeatureTips.wizardEquipItem(_loc_6);
                            }
                        }
                        else
                        {
                            MsgManager.showRollTipsMsg(Language.getString(20726), MsgRollTipsType.msgRollTips3);
                        }
                    }
                    else if (ItemsUtil.isFashionEquip(param2))
                    {
                        if (ItemsUtil.isBind(param2))
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.FashionDressFashionEquip, param2));
                        }
                        else
                        {
                            ItemFeatureTips.fashionEquipItem(param2);
                        }
                    }
                    break;
                }
                case ItemMenuConst.BULKUSE:
                {
                    ItemFeatureTips.bulkUse(param2);
                    break;
                }
                case ItemMenuConst.APPLY:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Guild_wareHouse_itemMenuClick, {itemData:param2, operate:ItemMenuConst.APPLY}));
                    break;
                }
                case ItemMenuConst.EXTRACTION:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Guild_wareHouse_itemMenuClick, {itemData:param2, operate:ItemMenuConst.EXTRACTION}));
                    break;
                }
                default:
                {
                    break;
                    break;
                }
            }
            return;
        }// end function

    }
}
